import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { User } from '../models/user';
import { Observable } from 'rxjs';

@Injectable({
  providedIn: 'root'
})

export class RegisterService {
  constructor(
    private http: HttpClient
  ) { }

  public sendUser(user: User): Observable<any> {
    const url = 'http://localhost:8080/user/register';
    const httpOptions = {
      headers: new HttpHeaders({ 'Content-Type': 'application/json' })
    };

    return this.http.post<User>(url, user, httpOptions);
  }
}
